package com.hpin.fansea.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpin.fansea.R;
import com.hpin.fansea.bean.MyMessageResult;

import java.util.List;

/**
 * Created by Aaron on 15/9/23.
 */
public class MyMessageAdapter extends BaseAdapter {

    private Context context;
    private List<MyMessageResult.MyMessageDetail> myMessaglList;

    public MyMessageAdapter(Context context, List<MyMessageResult.MyMessageDetail> myMessaglList) {
        this.context = context;
        this.myMessaglList = myMessaglList;
    }

    public void setMyMessaglList(List<MyMessageResult.MyMessageDetail> myMessaglList) {
        this.myMessaglList = myMessaglList;
    }

    @Override
    public int getCount() {
        return myMessaglList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoleder holeder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_my_message, null);
            holeder = new ViewHoleder();
            holeder.news_name = (TextView) convertView.findViewById(R.id.my_news_name);
            holeder.news_time = (TextView) convertView.findViewById(R.id.my_news_time);

            convertView.setTag(holeder);

        } else {
            holeder = (ViewHoleder) convertView.getTag();
        }

        MyMessageResult.MyMessageDetail myMessageDetail = myMessaglList.get(position);
        holeder.news_name.setText(myMessageDetail.messageContent);
        holeder.news_time.setText(myMessageDetail.createMonth + "月" +myMessageDetail.createDay + "日");

        return convertView;
    }

    class ViewHoleder {
        private TextView news_name, news_time;
    }
}
